using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class UIMathUtil
{
    public static float CIRCLE_RAD = 2 * Mathf.PI;
    public static float CalculateRad(float cos, float sin)
    {
        var acos = Mathf.Acos(cos);
        return sin > 0 ? acos : CIRCLE_RAD - acos;
    }

    public static float OffsetRad(float rad, float offset)
    {
        rad += offset;
        return rad - Mathf.Floor(rad / CIRCLE_RAD) * CIRCLE_RAD;
    }

    public static int RadInCircleParts(float rad, int parts)
    {
        var partRange = CIRCLE_RAD / parts;
        var halfPart = partRange / 2;

        return Mathf.FloorToInt(OffsetRad(rad, halfPart) / partRange);
    }
}